define(['config/appregister',
'business/personalcenter/service/personalhttp',
	"jquery","date",
	"business/services/constant",
'business/services/personCenterComp',
'business/services/detailNavComp',
	'business/services/cutPicture',
	"business/personalcenter/directive/upload1",
"domReady",
"dragsort","business/personalcenter/directive/date","business/services/filter"], function(app, httpServices,$,constant) {
	app.controller('myaccountCtrl', function($scope, $state, $http,auth) {
		auth.isPersonLogin();
		$scope.dataType=1;
		var newemail = getQueryString("email");
		var verifyCode = getQueryString("verifyCode");
		var verifyToken = getQueryString("verifyToken");
		$scope.usersrc = "";
		//修改邮箱重定向
		if(newemail !== "" && verifyCode !== "" && verifyToken !== "") {
			var req = {
				type:'POST',
				uri:'modifyEmailWithCheckNewPhoneCode',
				data:{
					verifyToken: verifyToken,
					newEmail: newemail,
					verifyCode: verifyCode					
				}
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$(".modemlokbox").show();
						$(".myaccount-center-top li:nth-child(1)").attr("id", "");
						$(".myaccount-center-top li:nth-child(2)").attr("id", "mya-c-t-btn");
						$(".myaccount-center-top li:nth-child(3)").attr("id", "");
						$(".user-security").show();
						$(".a-infor").hide();
						$(".myaccount-center-c").hide();
						$(".myaccount-center-c-s").hide();
						setTimeout(function(){
							$(".modemlokbox").hide();
						},2000)
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				alert("重定向请求失败");
			});
			
		}
		
		//新手机div开关
		$scope.onNewphonediv = function() {
			$(".newphonediv").hide();
		}

		//获取用户基本信息
		getuserinfo();
		function getuserinfo() {
			var req = {
				type:'GET',
				uri:'getBaseUeserInfo'
			};
			httpServices.getuserHttpService(req).success(function(data) {
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.UserInfo = {
							coinValue: data.data.coinValue, //E币余额
							userId: data.data.userId, //用户id
							email: data.data.email,	//用户邮箱
							logo: data.data.logo, //用户头像
							phone: data.data.phone, //用户手机号码
							userType: data.data.userType //用户类型  1：个人用户  ,2：企业用户
						}
						if(!$scope.phone) {
							var strz = $scope.UserInfo.phone;
							var lez = strz.substring(0, 3);
							var riz = strz.substring(7, 11);
							$scope.phone = lez + "****" + riz;
						}
						if(!$scope.email) {
							var strs = $scope.UserInfo.email;
							var les = strs.substring(0, 3);
							var ris = strs.substring(7, 99);
							$scope.email = les + "****" + ris;
						}
					}else {
						console.log(data.msg);
					}
				});
			}).error(function() {
				alert("获取用户基本信息请求失败");
			});
		};
		
		
		//中间菜单跳转
		$scope.topgo = function(num) {
			if(num == 1) {
				$state.go("bloglist");
			}
			if(num == 2) {
				$state.go("resume.posted");
			}
			if(num == 3) {
				$state.go("myMainPage",{userId:$scope.UserInfo.userId});
			}
			if(num == 4) {
				$state.go("homepage");
			}
		};
		
		//邮箱 点击修改
		$scope.openemailmoddiv = function() {
			$(".modifyemail-onebox").show();
			getimg();
		};
		$scope.emailimg = function() {
			getimg();
		};
		
		//修改邮箱第一步，请求图片验证码	
		function getimg() {
			var req = {
				type:'GET',
				uri:'modifyEmailWithVerifyCode'
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0){
						delCookie("verifyToken");
						$scope.emailimgsrc = data.data.img;
						var arr = data.data.verifyToken;
						var arred = arr.split(",");
						$scope.verifyToken = arred[0];
						var expireTime = arred[1];
						var exp = new Date();
						exp.setTime(exp.getTime() + expireTime);
						document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
						console.log($scope.verifyToken,"这是第一步");
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				alert("修改邮箱第一步图片验证码请求失败")
			});
		};
		
		//关闭 邮箱第一个box
		$scope.offonebox = function() {
			$(".modifyemail-onebox").hide();
		};
		
		//点击获取短信验证码
		$scope.getmsgcode = function() {
			getemlphonecode();
		};
		function getemlphonecode() {
			var href = window.location.href;
			var phone = $("#onebox-input1").val();
			var code = $("#onebox-input2").val().toUpperCase();
			if(phone !== "" && code !== "") {
				var req = {
					type:'POST',
					uri:'modifyEmailWithSendPhoneCode',
					data:{
						phone: phone,
						verifyCode: code,
						verifyToken: $scope.verifyToken,
						seed:localStorage.seed,
						authToken:localStorage.authToken
					}
				};
				
				$.ajax({
					type:'post',
					dataType:'json',
					url:"http://"+allUrl+":8080/elink_user/api/user/modifyEmailWithSendPhoneCode",
					data:req.data,
					success:function(data) {
						if(!data)return;
						$scope.$apply(function(){
							if(data.code == 0) {
								$('#getto').unbind("click");
								$("#getto").html("重新获取(<span id=" + 'time' + ">150</span>s)");
								var timer = $("#time").html();
								var mytime = setInterval(function() {
									if(timer > 0) {
										timer--;
										timer = timer;
									} else {
										clearInterval(mytime);
										$("#getto").html("重新获取");
										$('#getto').bind("click");
									}
									$("#time").html(timer);
								}, 1000)
		
							} else {
								alert(data.msg);
							}
						});						
					},
					error:function() {
						alert('获取手机短信验证码请求失败');
					}
				})
			} else {
				alert("手机号码/验证码不能为空");
			}
		};
		
		//第一个邮箱盒子点击验证身份
		$scope.checkId = function() {
			emailcheckId();
		};
		function emailcheckId() {
			var phone = $("#onebox-input1").val();
			var code = $("#onebox-input3").val().toUpperCase();
			if(phone !== "" && code !== "") {
				var req = {
					type:'POST',
					uri:'modifyEmailWithCheckPhoneCode',
					data:{
						phone: phone,
						verifyCode: code,
						verifyToken: $scope.verifyToken
					}
				};
				httpServices.getuserHttpService(req).success(function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code == 0) {
							$(".modifyemail-onebox").hide();
							$(".emailmoddiv").show();
							getbox2img();
						} else {
							console.log(data.msg);
						}
					});
				}).error(function(){
					alert("身份验证请求失败");
				});
			}else {
				console.log("有空参数")
			}
		};

		//获取邮箱box2的图片验证码
		$scope.getbox2pic = function() {
			getbox2img();
		}
		function getbox2img() {
			var req = {
				type:'GET',
				uri:'modifyEmailWithNewVerifyCode'
			};
			$.ajax({
				type:'get',
				dataType:'json',
				data:{
					verifyToken: $scope.verifyToken
				},
				url:"http://"+allUrl+":8080/elink_user/api/user/modifyEmailWithNewVerifyCode",
				success:function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code==0){
							delCookie("verifyToken");
							$scope.emailimgsrcs = data.data.img;
							var arr = data.data.verifyToken;
							var arred = arr.split(",");
							$scope.verifyToken = arred[0];
							var expireTime = arred[1];
							var exp = new Date();
							exp.setTime(exp.getTime() + expireTime);
							document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
						}else {
							console.log(data.msg);
						}
					});					
				},
				error:function(){
					console.log("修改邮箱第4步图片验证码请求失败");
				}
			})
		};


		//点击绑定新邮箱
		$scope.bindNewEmail = function() {
			bindneweml();
		};
		$scope.closeTip=function(){
			$(".cdxbox").hide();
		};
		function bindneweml() {
			var href = window.location.href;
			var newemail = $("#newEmail").val();
			var code = $("#newCode").val().toUpperCase();
			if(href !== "" && newemail !== "" && code !== "") {
				var req = {
					type:'POST',
					uri:'modifyEmailWithSendNewPhoneCode',
					data:{
						redirectUrl: href,
						newEmail: newemail,
						verifyCode: code,
						verifyToken: $scope.verifyToken
					}
				};
				
				$.ajax({
					type:'post',
					dataType:'json',
					data:req.data,
					url:"http://"+allUrl+":8080/elink_user/api/user/modifyEmailWithSendNewPhoneCode",
					success:function(data){
						if(!data)return;
						$scope.$apply(function(){
							if(data.code == 0) {
								$(".emailmoddiv").hide();
								$(".cdxbox").show();
								setTimeout(function(){
									$(".cdxbox").hide();
								},600)
							} else {
								alert(data.msg);
							}						
						});						
					},
					error:function(){
						alert("邮箱绑定请求失败")
					}
				})
			} else {
				console.log("有空参数");
			}
		};

		//重定向后验证
		function getQueryString(name) {
			// 如果链接没有参数，或者链接中不存在我们要获取的参数，直接返回空 
			if(location.href.indexOf("?") == -1 || location.href.indexOf(name + '=') == -1) {
				return '';
			}
			// 获取链接中参数部分 
			var queryString = location.href.substring(location.href.indexOf("?") + 1);

			// 分离参数对 ?key=value&key2=value2 
			var parameters = queryString.split("&");

			var pos, paraName, paraValue;
			for(var i = 0; i < parameters.length; i++) {
				// 获取等号位置 
				pos = parameters[i].indexOf('=');
				if(pos == -1) {
					continue;
				}
				// 获取name 和 value 
				paraName = parameters[i].substring(0, pos);
				paraValue = parameters[i].substring(pos + 1);
				// 如果查询的name等于当前name，就返回当前值，同时，将链接中的+号还原成空格 
				if(paraName == name) {
					return unescape(paraValue.replace(/\+/g, " "));
				}
			}
			return '';
		};

		$scope.userid = '';
		
		//个人档案回显
		get();
		function get() {
			$scope.tabTypeFlag=false;
			$scope.accountFlag=true;
			var req = {
				type:'GET',
				uri:'getCurrentPersonInfo'
			};
			httpServices.getpersonHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0&&data.data!=null) {
						$scope.userInfoList=data.data;
						if(data.data.sex == 1 ) {//男的
							$scope.thesexs = "男";
						}else if(data.data.sex == 2 ) {//女的
							$scope.thesexs = "女";
						}else {
							$scope.thesexs = "";
						}
						$scope.carrerTopId = data.data.carrerTopId;//职业规划一级分类ID
						var str = data.data.phone;
						var le = str.substring(0, 3);
						var ri = str.substring(7, 11);
						$scope.statuid = data.data.carrerStatusId;
						getTimer(data.data.birthday);
						$scope.phone = le + "****" + ri;
						$scope.email = data.data.email;
						$scope.nickname = data.data.nickname;
						$scope.address = data.data.address;
						$scope.birthday = data.data.birthday;
						$scope.sex = data.data.sex;

						$scope.introduction = data.data.introduction;
						$scope.userid = data.data.userId;
						$scope.usersrc = data.data.logo;
						var threeid = data.data.professionalThirdId;
						var twoid = data.data.professionalSecondId;
						$scope.hierid = data.data.carrerStatusId;
						if(data.data.sex == 1) {
							$("#nan").attr("checked", true);
						} else if(data.data.sex == 2) {
							$("#nv").attr("checked", true);
						}
						if(data.data.carrerStatusId == 1) {
							zhiYe($scope.userInfoList.carrerTopId);
							$("#job").attr("checked", true);
							getCareerPlann($scope.carrerTopId);
							$(".font-top").html("所选职业：");
							$("#fk").show();
							$("#fk2").hide();
							$("#fk3").hide();
							$scope.zhiyezhuangtai = "在职";
						}
						if(data.data.carrerStatusId == 2) {
							zhiYe($scope.carrerTopId);
							$("#getjob").attr("checked", true);
							getCareerPlann($scope.carrerTopId);
							$(".font-top").html("所选职业：");
							$("#fk").show();
							$("#fk2").hide();
							$("#fk3").hide();
							$scope.zhiyezhuangtai = "求职";
						}						
						if(data.data.carrerStatusId == 3) {
							zhuanYe(data.data.professionalSecondId,data.data.professionalThirdId);
							var prosId = data.data.professionalSecondId;
							var protId = data.data.professionalThirdId;
							$("#student").attr("checked", true);
							$(".font-top").html("所选专业：");
							$("#fk").hide();
							$("#fk2").show();
							$("#fk3").show();
							$scope.zhiyezhuangtai = "学生";
							getstudent();
							gettwoid(prosId);
							getthreeid(prosId,protId);
							$("#fk2 option[value='prosId']").attr("selected", true);
							$("#fk3 option[value='protId']").attr("selected", true);

						}
						
						$scope.xian = data.data.areaId;
						var theqid = data.data.regionId;
						var thexid = data.data.areaId;
						var theid = data.data.provinceId;
						var thexq = data.data.databaseSecondId;
						var thexq2 = data.data.databaseThirdId;
						
						$scope.databaseTwo = data.data.databaseSecondId;
						$scope.databaseThree = data.data.databaseThirdId;
						$scope.professionalSId = data.data.professionalSecondId;
						$scope.professionalTId = data.data.professionalThirdId;
						getprovince();
						getCity(data.data.provinceId);
						getArea(data.data.regionId);
						//$("#s option[value='theid']").attr("selected", true);
						
						//兴趣类目
						interest(thexq);
						interest2(thexq,thexq2);
						$("#interest option[value='thexq']").attr("selected", true);
						$("#interest2 option[value='thexq2']").attr("selected", true);
						suozaidi(data.data.provinceId,data.data.regionId,data.data.areaId);
						ganxinqu(data.data.databaseSecondId,data.data.databaseThirdId);
					
						
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				alert("个人档案请求失败");
			});
		};
		
		
		//职业分类回显
		var zhiname;
		function zhiYe(a) {
			if(!a){a=0};
			var req = {
				type:'GET',
				uri:'getHierInfo',
				data:{
					hierId:a,
				}
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.suoxuanzhuanye= data.data.hierName;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){});			
		}
		
		
		//专业分类回显
		var zaname,zbname;
		function zhuanYe(a,b) {
			if(!a){a=0};
			if(!b){b=0};
			var req = {
				type:'GET',
				uri:'getInfo',
				data:{
					scId:a,
					dcId:b
				}
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						console.log(data.data);
						zaname = data.data.scName;
						zbname = data.data.dcName;
						$scope.suoxuanzhuanye = zaname+"-"+zbname;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){});				
		}
		
		//感兴趣的类目回显
		var daname,dbname;
		function ganxinqu(a,b) {
			if(!a){a=0};
			if(!b){b=0};
			var req = {
				type:'GET',
				uri:'getInfo',
				data:{
					scId:a,
					dcId:b
				}
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						daname = data.data.scName;
						dbname = data.data.dcName;
						$scope.ganxinqu = daname+"-"+dbname;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){});			
		}
		
		//所在地回显
		var aname,bname,cname;
		function suozaidi(a,b,c) {
			if(!a){
				a = 0;
			}
			if(!b){
				b = 0;
			}
			if(!c){
				c = 0;
			}
			var req = {
				type:'GET',
				uri:'getAreaInfo',
				data:{
					provinceId:a,
					regionId:b,
					areaId:c
				}
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						aname = data.data.provinceName;
						bname = data.data.regionName;
						cname  = data.data.areaName;
						$scope.suozaidi = aname+"-"+bname+"-"+cname+"-"+$scope.address;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){});				
			
			
		}
		
		//处理文件格式
		function getimgfy(imgSrc){
			if(imgSrc.indexOf("base64,")<0) {
				return imgSrc
			}else{
				return  imgSrc.substr(imgSrc.indexOf("base64,")+7,imgSrc.length)
			}
		};
		
		//点击编辑按钮
		$scope.bianji = function() {
			$scope.accountFlag=false;
			$scope.tabTypeFlag=true;
		};
		
		
		//点击省
		$scope.schange = function(x) {
			getCity(x);
		};
		//点击市
		$scope.cchange = function(x) {
			getArea(x);
		};		

		//获取省
		function getprovince(){
			var req = {
				type:'GET',
				uri:'getProvinceList'
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.province = data.data;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log("省请求失败");
			});	
		};

		//获取城市
		function getCity(id) {
			var req = {
				type:'GET',
				uri:'getRegionListInProvince',
				data:{
					provinceId:id
				}
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.region = data.data;
						$scope.userInfoList.regionId=$scope.region[0].regionId;
						getArea($scope.region[0].regionId);
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log("市请求失败");
			});				
		};
		
		//获取区
		function getArea(a) {
			if(!a)return;
			var req = {
				type:'GET',
				uri:'getAreaListInRegionId',
				data:{
					regionId: a
				}
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.areas = data.data;
						$scope.userInfoList.areaId=$scope.areas[0].areaId;
					}else {
						console.log(data.msg);
					}
				});
			}).error(function(){
				console.log("区/县请求失败");
			});				
		};
		//生日
		//设置时间/回显时间
		$scope.bir={year:'',month:'',day:''};
		function getTimer(a) {
			var newtime = new Date(a);
			$scope.bir.year = newtime.getFullYear();
			$scope.bir.month = newtime.getMonth()+1;
			$scope.bir.day = newtime.getDate();
			$scope.theyear = $scope.bir.year;
			$scope.themonth = $scope.bir.month;
			$scope.theday = $scope.bir.day;
		};
		setTime(1950,12,31);

		function setTime(aa,mm,dd) {
			$scope.years = [];
			$scope.months = [];
			$scope.days = [];
			var times = new Date();
			var y = times.getFullYear();

			for (var i = aa; i <= y; i++) {
				var years = {
					year:i
				}
				$scope.years.push(years);
			}
			for (var z = 1; z <= mm; z++) {
				var months = {
					month:z
				}
				$scope.months.push(months);
			}
			for (var c = 1; c <= dd; c++) {
				var days = {
					day:c
				}
				$scope.days.push(days);
			}
		};
		function setDays(d){
			$scope.days = [];
			for (var c = 1; c <= d; c++) {
				var days = {
					day:c
				}
				$scope.days.push(days);
			}
		}
		$scope.monthchange = function(x){
			var theyear =$scope.bir.year;
			if(x === 1||x === 3||x === 5||x === 7||x === 8||x === 10||x === 12) {
				setDays(31);
			}
			if(x==4||x==6||x==9||x==11) {
				setDays(30);
			}
			if(x==2){
				if ((theyear % 4 == 0) && (theyear % 100 != 0) || (theyear % 400 == 0)){
					setDays(29);
				}else {
					setDays(28);
				}
			}				
		};
		$("#hns").hide();
		$("#stus").hide();
		$("#stut").hide();
		$("#ss").hide();
		$("#cs").hide();
		$("#as").hide();
		$("#int1").hide();
		$("#int2").hide();
		//修改个人档案
		$scope.mpf = function() {
			var birthday = $scope.bir.year+"-"+$scope.bir.month+"-"+$scope.bir.day;
			console.log(birthday)
				if($scope.userInfoList.databaseSecondId == ""||$scope.userInfoList.databaseSecondId==undefined){
					alert("感兴趣的类目是必选项");
					return;
				}
				if($scope.userInfoList.carrerStatusId==''||$scope.userInfoList.carrerTopId==''||$scope.userInfoList.carrerStatusId==undefined||$scope.userInfoList.carrerTopId==undefined) {
						alert("请选择职业状态");
						return;
				}
				if(!$scope.userInfoList.userId) {
					alert("未登录，无法操作");
					return;
				}
				if($scope.userInfoList.nickname == "" || $scope.userInfoList.nickname == undefined){
					alert("昵称是必填项");
				 	return;
				}
				var req = {
					type:'POST',
					uri:'modifyPersonInfo',
					data:{
						nickname: $scope.userInfoList.nickname,
						logo:getimgfy($scope.usersrc),
						sex: $scope.userInfoList.sex,
						birthday: birthday,
						provinceId: $scope.userInfoList.provinceId,
						regionId: $scope.userInfoList.regionId,
						areaId: $scope.userInfoList.areaId,
						address: $scope.userInfoList.address,
						introduction: $scope.userInfoList.introduction,
						userId: $scope.userInfoList.userId,
						carrerStatusId:  $scope.userInfoList.carrerStatusId,//职业状态 1，2是在职求职 3是学生
						professionalSecondId:$scope.professionalSId,//所选专业一级分类
						professionalThirdId:$scope.professionalTId,//所选专业二级分类
						databaseSecondId: $scope.userInfoList.databaseSecondId,//感兴趣的类目一级分类
						databaseThirdId: $scope.userInfoList.databaseThirdId,//感兴趣的类目二级分类
						carrerTopId: $scope.userInfoList.carrerTopId,//职业一级分类
						"seed": localStorage.seed ,
						"authToken" :localStorage.authToken,
					}
				};
				$.ajax({
					type: "post",
					dataType: "json",
					data:req.data,
					url: "http://"+allUrl+":8080/elink_user/api/person/modifyPersonInfo",
					success: function(result) {
						$scope.$apply(function() {
							$(".oks").show();
							setTimeout(function(){
								$(".oks").hide();
								get();
							},2000);							
						});
					},
					error: function(jqXHR) {
						console.log("修改个人档案请求失败");
					}
				});
		};

		$scope.hideoks = function() {
			$(".oks").hide();
		};
		//点击兴趣类目
		$scope.int1change = function(x) {
			interest2(x);
		};
		//感兴趣的类目
		function interest(a) {
			var req = {
				type:'GET',
				uri:'getSecondaryCategory',
				data:{
					tcId:1
				}
			};
			httpServices.getdataHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.interdata = data.data;
					} else {
						console.log(data.msg);
					}					
				});
			}).error(function(){
				alert("感兴趣类目请求失败");
			});
		};
		function interest2(aa) {
			var req = {
				type:'GET',
				uri:'getDetailCategory',
				data:{
					scId:aa
				}
			};
			httpServices.getdataHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.interdata2 = data.data;
						$scope.userInfoList.databaseThirdId=$scope.interdata2[0].dcId;
					} else {
						console.log(data.msg);
					}					
				});
			}).error(function(){
				alert("感兴趣类目三级请求失败");
			});
		};
		//职业状态动作
		$("input[name='radio2']").click(function() {
			var id = $(this).attr("id");
			if(id == "job" || id == "getjob") {
				$("#fk").show();
				$("#fk2").hide();
				$("#fk3").hide();
				$(".font-top").html("所选职业：");
				getCareerPlann($scope.hierid);
			} else if(id == "student") {
				getstudent();
			}
		});
		//
		function gettwoid(a) {
			var req = {
				type:'GET',
				uri:'getSecondaryCategory',
				data:{
					tcId:3
				}
			};
			httpServices.getlibHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.studentSecondall = data.data;
						if(!a) {
							$("#stus").hide();
							$scope.studentSecond = $scope.studentSecondall[0];
						}else {
							for(var i = 0;i<$scope.studentSecondall.length;i++) {
								if(a==$scope.studentSecondall[i].scId) {
									$scope.studentSecond = $scope.studentSecondall[i].scName;
								}
							}							
						}
					} else {
						console.log(data.msg);
					}					
				});				
				
				
			}).error(function(){
				alert("学生分类请求失败");
			});
		};
		
		//学生
		function getstudent() {
			var req = {
				type:'GET',
				uri:'getSecondaryCategory',
				data:{
					tcId:3
				}
			};
			httpServices.getlibHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$("#fk").hide();
						$("#fk2").show();
						$("#fk3").show();
						$(".font-top").html("所选专业：");
						$scope.studentSecondall = data.data;
						$scope.studentSecond = data.data[0].scName;
						$scope.studentSchange = function(the) {
							if(!the)return;
							$("#stus").hide();
							$("#stut").hide();
							var req = {
								type:'GET',
								uri:'getDetailCategory',
								data:{
									scId:the.scId
								}
							};
							httpServices.getlibHttpService(req).success(function(data){
								if(!data)return;
								$scope.$apply(function(){
									if(data.code == 0) {
										$scope.studentThreeall = data.data;
										$scope.studentThree = data.data[0].dcName;	
									} else {
										console.log(data.msg);
									}
								});
							}).error(function(){
								alert("学生三级分类请求失败");
							});		
						};
					} else {
						console.log(data.msg,"学生");
					}					
				});
			}).error(function(){
				alert("学生分类请求失败");
			});
		};
		
		function getthreeid(aa,bb) {
			var req = {
				type:'GET',
				uri:'getDetailCategory',
				data:{
					scId:aa
				}
			};
			httpServices.getlibHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.studentThreeall = data.data;
						if(!bb) {
							$("#stut").hide();
							$scope.studentThree = $scope.studentThreeall[0];
						}else {
							for(var i = 0;i<$scope.studentThreeall.length;i++) {
								if(bb==$scope.studentThreeall[i].dcId) {
									$scope.studentThree = $scope.studentThreeall[i].dcName;
								}
							}							
						}						
					} else {
						console.log(data.msg);
					}					
				});				
			}).error(function(){
				alert("学生二级分类请求失败");
			});			
		};
		//在职 和求职
		function getCareerPlann(aas) {
			var req = {
				type:'GET',
				uri:'getCareerPlann',
				data:{
					count:10
				}
			};
			httpServices.getvideoHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$("#fk").show();
						$("#fk2").hide();
						$("#fk3").hide();
						$scope.qiuzhi = data.data.list;
						if(aas){
							for(var i=0;i<$scope.qiuzhi.length;i++) {
								if(aas==$scope.qiuzhi[i].hierId) {
									$scope.hierNames = $scope.qiuzhi[i];
									$scope.hierIds = $scope.qiuzhi[i].hierId;
									return;
								}
							}
						}else {
							$("#hns").hide();
							$scope.hierNames = $scope.qiuzhi[0].hierName;
							$scope.hierIds = $scope.qiuzhi;
						}
					} else {
						console.log(data.msg,"在职求职");
					}					
				});
			}).error(function(){
				alert("求职在职分类请求失败");
			});
		};
		
		//市
		getciti();
		function getciti() {
			$(".selectone").change(function() {
				//获取省id 
				var the = $(this).children("option:selected").val();
				var citi = "/elink_user/api/selector/getRegionListInProvince?provinceId=";
				
				var req = {
					type:'GET',
					uri:'getRegionListInProvince',
					data:{
						provinceId:the
					}
				};
				httpServices.getcitiHttpService(req).success(function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code==0) {
							$scope.citi = data.data;
							$(".selecttwo").change(function() {
								var thes = $(this).children("option:selected").val();
								var req = {
									type:'GET',
									uri:'getAreaListInRegionId',
									data:{
										regionId:thes
									}
								};
								httpServices.getcitiHttpService(req).success(function(data){
									if(!data)return;
									if(data.code==0){
										$scope.citis = data.data;
									}else {
										console.log(data.msg,"县");
									}
								}).error(function(){
									alert("县请求失败");
								});
							});							
						}else {
							console.log(data.msg,"城市");
						}
					})
				}).error(function(){
					alert("城市请求失败");
				});
			});
		};

		//省
		province();
		function province() {
			var req = {
				type:'GET',
				uri:'getProvinceList',
			};
			httpServices.getcitiHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0) {
						$scope.province = data.data;
					}else {
						console.log(data.msg,"省");
					}
				})
			}).error(function(){
				alert("省请求失败");
			});
		};

		//
		$scope.clickok = function() {
			$(".ok").hide();
		};
		$scope.onpswddiv = function() {
			$(".pswdmoddiv").hide();
		};
		$scope.onemailmoddiv = function() {
			$(".emailmoddiv").hide();
		};
		$scope.openphonemoddiv = function() {
			$(".phonemoddiv").show();
			modifygetpic();
		};
		$scope.onphonemoddiv = function() {
			$(".phonemoddiv").hide();
		};
		$scope.modpswdbtn = function() {
			$(".pswdmoddiv").show();
		};
		
		
		//跳转到会员等级规则
		$scope.gotoVip = function() {
			$scope.inforbtn4();
		}
		
		
		//个人账户安全 修改密码
		$scope.pswdmod = function() {
				var pswd1 = $("#pswd1").val();
				var pswd2 = $("#pswd2").val();
				var pswd3 = $("#pswd3").val();
				if(pswd2 !== pswd3) {
					$(".pswdtip").show().html("两次输入不一致");
					return false;
				}
				if(pswd2 == pswd3 && pswd1 !== "" && pswd2 !== "" && pswd3 !== "") {
					var req = {
						type:'POST',
						uri:'modifyPasswd',
						data:{
							passwd: pswd1,
							newPasswd: pswd2,
							verifyToken: $scope.verifyToken
						}
					};
					httpServices.getuserHttpService(req).success(function(data){
						if(!data)return;
						$scope.$apply(function(){
							if(data.code == 0) {
								$(".ok").show();
								setTimeout(function(){
									$(".ok").hide();
								},1500)
								$(".pswdmoddiv").hide();
								$(".pswdtip").hide();
							} else {
								console.log(data.msg);
							}							
						});
					}).error(function(){
						alert("修改密码put请求失败");
					});
				} else {
					$(".pswdtip").show().html("输入错误！请检查");
				}
		};
			
		//修改手机号流程一 
		$scope.clickimg = function() {
			modifygetpic();
		};
		function modifygetpic() {
			var req = {
					type:'GET',
					uri:'modifyPhoneWithVerifyCode'
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0){
						delCookie("verifyToken");
						$scope.phoneimgsrc = data.data.img;
						var arr = data.data.verifyToken;
						var arred = arr.split(",");
						$scope.verifyToken = arred[0];
						var expireTime = arred[1];
						var exp = new Date();
						exp.setTime(exp.getTime() + expireTime);
						document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
					}else {
						console.log(data.msg);
					}
				});				
			}).error(function(){
				alert("验证码图片请求失败");
			});
		};

		//修改邮箱流程一
		$scope.clickimg2 = function() {
			modifygetpic2();
		};
		function modifygetpic2() {
			var req = {
					type:'GET',
					uri:'modifyEmailWithVerifyCode'
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0){
						delCookie("verifyToken");
						$scope.imgsrc = data.data.img;
						var arr = data.data.verifyToken;
						var arred = arr.split(",");
						$scope.verifyToken = arred[0];
						var expireTime = arred[1];
						var exp = new Date();
						exp.setTime(exp.getTime() + expireTime);
						document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
					}else {
						console.log(data.msg);
					}
				});				
			}).error(function(){
				alert("验证码图片请求失败");
			});			
		};

		//修改邮箱流程二
		$scope.dothebtn = function() {
			getphoneverifycode();
		};
		function getphoneverifycode() {
			var phone = $(".nowphone").val();
			var verifycode = $(".piccodo").val().toUpperCase();
			if(phone !== "" && verifycode !== "") {
				var req = {
					type:'POST',
					uri:'modifyPhoneWithSendPhoneCode',
					data:{
						phone: phone,
						verifyCode: verifycode,
						verifyToken: $scope.verifyToken
					}
				};
				httpServices.getuserHttpService(req).success(function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code == 0) {
							$('#emailcsss').unbind("click");
							$("#emailcsss").html("重新获取(<span id=" + 'time' + ">150</span>)");
							var timer = $("#time").html();
							var mytime = setInterval(function() {
								if(timer > 0) {
									timer--;
									timer = timer;
								} else {
									clearInterval(mytime);
									$("#emailcsss").html("重新获取");
									$('#emailcsss').bind("click");
								}
								$("#time").html(timer);
							}, 1000)
						} else {
							console.log(data.msg);
						}						
					});
				}).error(function(){
					alert("获取短信验证码请求失败")
				});
			} else {
				console.log("参数为空")
				return false;
			}
		};
		
		//修改手机第三步
		$scope.verifyid = function() {
			phonethree();
		};
		function phonethree() {
			var phone = $(".nowphone").val();
			var msgcode = $(".phonecode").val().toUpperCase();
			if(phone !== "" && msgcode !== "") {
				var req = {
					type:'POST',
					uri:'modifyPhoneWithCheckPhoneCode',
					data:{
						phone: phone,
						verifyCode: msgcode,
						verifyToken: $scope.verifyToken
					}
				};
				httpServices.getuserHttpService(req).success(function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code == 0) {
							console.log("找回成功跳转新手机box");
							$(".phonemoddiv").hide();
							$(".newphonediv").show();
							newImg();
						} else {
							console.log(data.msg)
						}					
					});
				}).error(function(){
					alert("手机找回第三步请求失败");
				});
			} else {
				console.log("参数为空");
				return false;
			}
		};
		
		//新手机box图片验证码
		function newImg() {
			var req = {
					type:'GET',
					uri:'modifyPhoneWithNewVerifyCode',
					data:{
						verifyToken: $scope.verifyToken
					}
			};
			httpServices.getuserHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code==0){
						delCookie("verifyToken");
						$scope.newimgsrc = data.data.img;
						var arr = data.data.verifyToken;
						var arred = arr.split(",");
						$scope.verifyToken = arred[0];
						var expireTime = arred[1];
						var exp = new Date();
						exp.setTime(exp.getTime() + expireTime);
						document.cookie = "verifyToken=" + $scope.verifyToken + ";expires=" + exp.toGMTString();
					}else {
						console.log(data.msg);
					}
				});				
			}).error(function(){
				alert("验证码图片请求失败");
			});			
		};

		//改手机第六步
		function lastnewphone() {
			var newphone = $(".newphonenum").val();
			var newphoneverifycode = $(".newphoneverifycode").val().toUpperCase();
			if(newphone !== "" && newphoneverifycode !== "") {
				var req = {
					type:'POST',
					uri:'modifyPhoneWithCheckNewPhoneCode',
					data:{
						newPhone: newphone,
						verifyCode: newphoneverifycode,
						verifyToken: $scope.verifyToken
					}
				};
				httpServices.getuserHttpService(req).success(function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code == 0) {
							$(".newphonediv").hide();
							$(".newphoneok").show();
							setTimeout(function(){
								$(".newphoneok").hide();
								$state.go("login");
							},2000)
						} else {
							console.log(data.msg)
						}					
					});
				}).error(function(){
					alert("第六步请求失败");
				});
			} else {
				console.log("有空参数")
			}
		};

		//新手机号box点击获取短信验证码
		$scope.getphoneverifycode = function() {
			bindnewphone()
		};

		//新手机号box 点击最后的绑定新手机号按钮 
		$scope.bindnewphone = function() {
			lastnewphone();
		};
			//点击关闭第7步成功box
		$scope.onok = function() {
			$(".newphoneok").hide();
		};

		//改手机第5步 
		function bindnewphone() {
			var newphone = $(".newphonenum").val();
			var newphonepiccode = $(".newphonecodepic").val().toUpperCase();
			if(newphone !== "" && newphonepiccode !== "") {
				var req = {
					type:'POST',
					uri:'modifyPhoneWithSendNewPhoneCode',
					data:{
						newPhone: newphone,
						verifyCode: newphonepiccode,
						verifyToken: $scope.verifyToken
					}
				};
				httpServices.getuserHttpService(req).success(function(data){
					if(!data)return;
					$scope.$apply(function(){
						if(data.code == 0) {
							$('#getphonecode').unbind("click");
							$("#getphonecode").html("重新获取(<span id=" + 'time' + ">150</span>)");
							var timer = $("#time").html();
							var mytime = setInterval(function() {
								if(timer > 0) {
									timer--;
									timer = timer;
								} else {
									clearInterval(mytime);
									$("#getphonecode").html("重新获取");
									$('#getphonecode').bind("click");
								}
								$("#time").html(timer);
							}, 1000)							
						} else {
							console.log(data.msg)
						}						
					});
				}).error(function(){
					alert("改手机号码第五步请求失败");
				});
			} else {
				console.log("参数为空")
			}
		};

		//账户信息内部div切换
		$(".a-infor-l li a").css("color","#333");
		$(".infor-a-1").css("color","#30a3ff");
		$scope.inforbtn1 = function() {
			$(".a-infor-r1").show();
			$(".a-infor-r2").hide();
			$(".a-infor-r3").hide();
			$(".a-infor-r4").hide();
			$(".a-infor-r5").hide();
		};
		$scope.inforbtn2 = function() {
			$(".a-infor-l li a").css("color","#333");
			$(".infor-a-1").css("color","#30a3ff");
			$(".a-infor-r1").hide();
			$(".a-infor-r2").show();
			$(".a-infor-r3").hide();
			$(".a-infor-r4").hide();
			$(".a-infor-r5").hide();
		};
		$scope.inforbtn3 = function() {
			$(".a-infor-l li a").css("color","#333");
			$(".infor-a-2").css("color","#30a3ff");
			$(".a-infor-r1").hide();
			$(".a-infor-r2").hide();
			$(".a-infor-r3").show();
			$(".a-infor-r4").hide();
			$(".a-infor-r5").hide();
		};
		$scope.inforbtn4 = function() {
			$(".a-infor-l li a").css("color","#333");
			$(".infor-a-3").css("color","#30a3ff");
			$(".a-infor-r1").hide();
			$(".a-infor-r2").hide();
			$(".a-infor-r3").hide();
			$(".a-infor-r4").show();
			$(".a-infor-r5").hide();
		};
		$scope.inforbtn5 = function() {
			$(".a-infor-r1").hide();
			$(".a-infor-r2").hide();
			$(".a-infor-r3").hide();
			$(".a-infor-r4").hide();
			$(".a-infor-r5").show();
		};

		$scope.tabType='personalArchives';
		$scope.accountFlag=false;
		$scope.tabTypeFlag=false;
		$scope.topbtn=function(str){
			if(str=='accountInfo'){
				$scope.accountFlag=true;
			}else{
				$scope.accountFlag=false;
			}
			$scope.tabType=str;
			$scope.tabTypeFlag=false;
		};
		
		var begin;
		var end;
		//详情列表参数
        $scope.listParams = {
            currentTcId: "",
            currentScId:"",
            download: false,
            time: false,
            pageNo: 1,
            pageSize: 10,
            all: false,
            typeId: "",
            scId: "",
            dcId: "",
            keyWord:""
        };
		//获取E币获取记录
		function getCoinList(begin,end){
			if(begin == undefined){
				begin = "";
			}
			if(end == undefined){
				end = ""
			}
			var req = {
					type:'GET',
					uri:'getCoinList',
					data:{
						beginTime:begin,
						endTime:end,
						pageNo:$scope.listParams.pageNo,
						pageSize:$scope.listParams.pageSize
					}
			};
			httpServices.coinHttpService(req).success(function(response){
				$scope.$apply(function(){
					$scope.coin = response.data.list;
					$scope.totalItem = response.data.Pagination.totalCount;
                   	getListModel();
				});				
			})			
		}
		getCoinList();
		//E币获取记录跳转
		$scope.goDetail = function(item){
			if(item.typeId == 4 || item.typeId == 11 || item.typeId == 19 || item.typeId == 26 || item.typeId == 28 || item.typeId == 30){
				//跳转资料详情页
				$state.go('eng.techdetail',{fileId:item.fkId})
			}else if(item.typeId == 5 || item.typeId == 12 || item.typeId == 20 || item.typeId == 27 || item.typeId == 29 || item.typeId == 31){
				//跳转论文详情页
				$state.go('eng.libraryDetail',{thesisId:item.fkId})
			}else if(item.typeId == 6 || item.typeId == 15 || item.typeId == 21){
				//跳转企业对外
				$state.go('outIndexCtrl.homepageCtrl',{companyId:item.fkId})
			}else if(item.typeId == 7 || item.typeId == 13 || item.typeId == 22){
				//跳转视频页
				$state.go('videoPlay',{couseIdPlayId:item.fkId})
			}else if(item.typeId == 8 || item.typeId == 23){
				//跳转课程页
				$state.go('eng.vedioDetails',{courseId:item.fkId})
			}else if(item.typeId == 9 || item.typeId == 24){
				//跳转工程技能
				$state.go('eng.workDetailsCtrl',{skillId:item.fkId})
			}else if(item.typeId == 10 || item.typeId == 14 || item.typeId == 25){
				//跳转新闻页
				$state.go('eng.newsDetail',{newsId:item.fkId})
			}else if(item.typeId == 16 || item.typeId == 17 || item.typeId == 18){
				//跳转问答页
				$state.go('eng.vedioDetails',{courseId:item.fkId})
			}else if(item.typeId == 33 || item.typeId == 35 || item.typeId == 37){
				//跳转博文页 待定
				$state.go('eng.vedioDetails',{courseId:item.fkId})
			}else if(item.typeId == 32 || item.typeId == 34 || item.typeId == 36){
				//跳转职位详情页
				$state.go('zpdetailCtrl',{jobId:item.fkId})
			}
		}
		
		//全部
		$scope.getCoinByDate = function(type){
			$scope.dataType=type;
			var now = new Date();                    //当前日期
		    var nowDayOfWeek = now.getDay();         //今天本周的第几天
		    var nowDay = now.getDate();              //当前日
		    var nowMonth = now.getMonth();           //当前月
		    var nowYear = now.getYear();             //当前年
		    nowYear += (nowYear < 2000) ? 1900 : 0;  //
		
		    var lastMonthDate = new Date();  //上月日期
		    lastMonthDate.setDate(1);
		    lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
		    var lastYear = lastMonthDate.getYear();
		    var lastMonth = lastMonthDate.getMonth();
			if(type == 1){
				getCoinList();
				return;
			}
			if(type == 2){
				var getCurrentDate = new Date(nowYear, nowMonth, nowDay+1);
				var end  = formatDate(getCurrentDate);
				var getTodayBeginDate = new Date(nowYear, nowMonth, nowDay-1);
				var begin =  formatDate(getTodayBeginDate);
			}
			if(type == 3){
				//获得本周的开始日期
			    var getWeekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
			    var begin =  formatDate(getWeekStartDate);
			    //获得本周的结束日期
			    var getWeekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
			    var end =  formatDate(getWeekEndDate);
			}
			if(type == 4){
				//获得本月的开始日期
			    var getMonthStartDate = new Date(nowYear, nowMonth, 1);
			    var begin =  formatDate(getMonthStartDate);
			
			    //获得本月的结束日期
			    var getMonthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth));
			    var end =  formatDate(getMonthEndDate);
			}
			if(type == 5){
				//获得上月开始时间
				if(lastMonth == "12"){
					nowYear -= 1;
				}
				console.log(lastMonth,nowYear)
			    var getLastMonthStartDate = new Date(nowYear, lastMonth, 1);
			    var begin = formatDate(getLastMonthStartDate);
			
			    //获得上月结束时间
			    var getLastMonthEndDate = new Date(nowYear, lastMonth, getMonthDays(lastMonth));
			    var end = formatDate(getLastMonthEndDate);
			}
			console.log(begin,end);
			getCoinList(begin,end);
			
			
			//获得某月的天数
		    function getMonthDays(myMonth){
		        var monthStartDate = new Date(nowYear, myMonth, 1);
		        var monthEndDate = new Date(nowYear, myMonth + 1, 1);
		        var   days   =   (monthEndDate   -   monthStartDate)/(1000   *   60   *   60   *   24);
		        return   days;
		    }
		}
		
		$scope.$on('chooseDate',function(a,begin,end){
			getCoinList(begin,end)
		})
		$('.date-choose a').click(function(){
			$(this).addClass('active').siblings().removeClass();
		})
		
		//格式化日期：yyyy-MM-dd
	    function formatDate(date) {
	        var myyear = date.getFullYear();
	        var mymonth = date.getMonth()+1;
	        var myweekday = date.getDate();
			if(mymonth == 12){
				myyear -= 1;
			}
	        if(mymonth < 10){
	            mymonth = "0" + mymonth;
	        }
	        if(myweekday < 10){
	            myweekday = "0" + myweekday;
	        }
	        return (myyear+"-"+mymonth + "-" + myweekday);
	    }
	    
	    
	    function getListModel() {
			$scope.paginationConf = {
				currentPage: $scope.listParams.pageNo,
				totalItems: $scope.totalItem,
				//每页预览条数
				itemsPerPage: $scope.listParams.pageSize,
				//分页总数
				numberOfPages: Math.ceil($scope.totalItem / $scope.listParams.pageSize),
				// 实际分页长度
				pagesLength: 5,
				perPageOptions: [10, 20, 30, 40, 50],
				onChange: function(currentPage) {
					if(currentPage) {
						$scope.paginationConf.currentPage = currentPage;
					}
					$scope.list = [];
					$scope.listParams.pageNo = $scope.paginationConf.currentPage;
					getCoinList(begin,end);
				}
			};
		}
	    
	    $scope.$on('previewPath',function(a,b,c){
	    	$scope.ggg = b;
	    })
	    //实名认证
	    
	    	//判断实名认证状态
	    	isState();
	    	function isState() {
	    		$.ajax({
	    			type:"get",
	    			url:"http://"+allUrl+":8080/elink_user/api/user/getCertification?seed="+localStorage.seed+"&authToken="+localStorage.authToken,
	    			success:function(data) {
	    				if(!data)return;
	    				$scope.$apply(function(){
	    					if(data.code == 0) {
	    						if(data.data==null) {
	    							$(".realName>div").hide();
	    							$(".true-name").show();
	    						}else if(data.data.authStatus == 1) {
	    							//审核通过
	    							$(".realName>div").hide();
	    							$(".AuditIsok").show();
	    							$scope.id = data.data.id;
	    							$scope.name = data.data.name;

	    						}else if(data.data.authStatus == 0) {
	    							//审核中
	    							$(".realName>div").hide();
	    							$(".Audit").show();
	    							$scope.id = data.data.id;
	    							$scope.name = data.data.name;	    							
	    						}else if(data.data.authStatus == 2) {
	    							//审核失败
	    							$(".realName>div").hide();
	    							$(".AuditIsno").show();
	    							$scope.remarks = data.data.remarks;
	    						}
	    						
	    					}else {console.log(data.msg)}
	    				})
	    			},
	    			error:function() {alert("用户认证信息请求失败")}
	    		})
	    	}
	    
	    
	    $scope.gotoNull = function() {
	    	$(".realName>div").hide();
	    	$(".true-name").show();
	    }
	    
	    
	    $scope.buttons = function() {
	    	var name = $("#username").val();
	    	var id = $("#userid").val();
	    	if(name == "") {
	    		return alert("请输入您的姓名");
	    	}
	    	if(id == "") {
	    		return alert("请输入您的身份证号");
	    	}
	    	if(id.length != 15 || id.length != 18) {
	    		alert("请输入正确的身份证号");
	    		return;
	    	}
	    	
	    	if(!$scope.ggg) {
	    		alert("请上传手持证件图片");
	    		return;
	    	}
	    	
	    	
	    	
	    	$.ajax({
	    		type:"post",
	    		url:"http://"+allUrl+":8080/elink_user/api/user/addCertification",
				data:{
					name:name,
					id:id,
					img:$scope.ggg,
					seed:localStorage.seed,
					authToken:localStorage.authToken
				},
	    		success:function(data){
	    			if(!data)return;
	    			$scope.$apply(function(){
	    				if(data.code == 0) {
							$(".realName>div").hide();
							$(".Audit").show();
	    				}else {
	    					alert(data.msg);
	    				}
	    			})
	    		},
	    		error:function(){
	    			alert("实名认证请求失败")
	    		}
	    	});
	    }
	    
		function delCookie(name) {
			var exp = new Date();
			exp.setTime(exp.getTime() - 1);
			var cval=getCookie(name);
			if(cval!=null)
			document.cookie= name + "="+cval+";expires="+exp.toGMTString();
		};
		
		function getCookie(name) {
			var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
			if(arr=document.cookie.match(reg))
			return unescape(arr[2]);
			else
			return null;
		};



	});
});